#include <iostream>
using namespace std;

class Hero {
    public: 
        Hero(const string &name = "hello");
        ~Hero();
        void skill(void);
    private:
        string name;        
};
Hero::Hero(const string &name) {
    cout << "Hero()" << endl;
    this->name = name;
}
Hero::~Hero() {
    cout << "~Hero()" << endl;
}

class Shooter {
    public: 
        Shooter(int distance = 0);
        ~Shooter();
    private:
        int distance;
};
Shooter::Shooter(int distance) {
    cout << "Shooter()" << endl;
    this->distance = distance;
}
Shooter::~Shooter() {
    cout << "~Shooter()" << endl;
}

class Luban:public Hero, public Shooter {
    public:
        Luban(const string &name, const int distance, const int legLen); //构造函数
        ~Luban(void); //析构函数
        void show(void) const; 
    private:
        int legLen;    
};
// 对象成员的初始化， 必须在派生类的初始化列表中指定。 如果没有指定，默认调用对象成员的无参构造函数
Luban::Luban(const string &name, const int distance, const int legLen): Hero(name), Shooter(distance), legLen(legLen) {
    cout << "Luban()" << endl;
}
Luban::~Luban(void) {
    cout << "~Luban()" << endl;
}


int main(int argc, char const *argv[])
{
    Luban luban("luban", 100, 10);
    // 析构函数调用顺序和构造函数的调用顺序相反
    /*
        Hero()
        Shooter()
        Luban()
        ~Luban()
        ~Shooter()
        ~Hero()
    */
    return 0;
}
